﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// NotReviewedButNeeded
#pragma once

#include "GcmpDatabase.h"
#include "ElementId.h"
#include "NdbObject.h"
#include "ClassId.h"
#include "NdbPropertySchemaType.h"

namespace gcmp
{
    class IDbObjectArchive;
    class NdbObjectMemoryModelNode;
    class NdbObject;

    /// \brief 容器类对象基类
    class GCMP_DATABASE_EXPORT NdbObjectContainer: public NdbObject
    {
        DEFINE_CAST_DERIVED(gcmp::NdbObjectContainer, gcmp::NdbObject)
    public:
        /// \brief 报告容器内所含的ElementId
        virtual void ReportElementIds(
            std::set<ElementId> * pElementIds,
            std::unordered_map<ElementId, std::vector<std::wstring>, ElementIdHash> * pPaths,
            std::vector<std::wstring> * pCurrentPath
        ) const = 0;

        /// \brief 替换容器内所含ElementId
        virtual void ReplaceElementIds(const std::unordered_map<ElementId, ElementId, ElementIdHash> & oldToNewMap) = 0;

        /// \brief 是否含有ElementId
        virtual bool HasElementIdProperty() const = 0;

    public:
        virtual ~NdbObjectContainer(void) = 0;

        virtual NdbPropertySchemaType GetSchemaType() const = 0;

        virtual OwnerPtr<NdbObjectContainer> NdbClone()const = 0;

        virtual void NdbAssignByMove(OwnerPtr<NdbObjectContainer> opSource) = 0;

        virtual UInt64 NdbSerialize(IDbObjectArchive & dbObjectArchive, NdbPropertyUtils::BehavioursAdapter adapter) const = 0;

        virtual void NdbExtractObjectFromMemory(NdbObjectMemoryModelNode * pObjectMemoryModelNode, UInt32 majorVersion) = 0;

        virtual void CollectModuleGroupsOfNdbObject(std::set<Guid, GuidComparer>& moduleGroupsGuids) const = 0;

        virtual NdbObject* GetTopOwnerObject() const override;

        virtual bool SetOwnerObject(NdbObject* pOwnerObject);

    private:
        NdbObject* m_pTopOwnerObject = nullptr;
    };
}

